<?php

namespace lc\helpers;

class Response
{
    /**
     * @desc    成功返回
     * @param   mixed $data
     * @param   string $message
     * @return  \think\response\Json
     */
    public static function success($data = '', $message = 'Success')
    {
        return json(['code' => 20000, 'message' => $message, 'data' => $data]);
    }

    /**
     * @desc    失败返回
     * @param   string $message
     * @return  \think\response\Json
     */
    public static function fail($message = 'Fail')
    {
        return json(['code' => 1000, 'message' => $message, 'data' => '']);
    }

    /**
     * @desc    自定义返回
     * @param   int     $code
     * @param   string  $message
     * @param   mixed   $data
     * @return  \think\response\Json
     */
    public static function defined($code, $message, $data = '')
    {
        return json(['code' => $code, 'message' => $message, 'data' => $data]);
    }

    /**
     * @desc    鉴权未登录
     * @return  \think\response\Json
     */
    public static function unLogin()
    {
        return json(['code' => 1001, 'message' => '请先登录，再进行操作', 'data' => '']);
    }
}
